<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="js/jquery-3.6.0.js" type="text/javascript"></script>
</head>
<body>
<h3>请求参数绑定</h3>
<h5>相对路径</h5>
<a href="queryAccountByName?name=zhangsan&money=1000">基本数据类型绑定</a>
<h5>绝对路径</h5>
<a href="${pageContext.request.contextPath}/queryAccountByName?name=zhangsan&balance=1000">基本数据类型绑定</a>
<h5>pojo类型参数绑定</h5>
<form action="addAccount" method="post">
    账户名称:<input type="text" name="name"><br/>
    账户余额:<input type="text" name="balance"><br/>
    账户用户1:<input type="text" name="userList[0].name"><br/>
    账户用户1:<input type="text" name="userList[0].age"><br/>
    账户用户2:<input type="text" name="userList[1].name"><br/>
    账户用户2:<input type="text" name="userList[1].age"><br/>
    <button type="submit">提交</button>
</form>
<a href="${pageContext.request.contextPath}/testDate?date=2021-08-20">日期类型绑定</a><br/>
<a href="${pageContext.request.contextPath}/testReqRespSe">reqresp</a><br/>
<a href="${pageContext.request.contextPath}/testHeader">测试请求头</a><br/>
<a href="${pageContext.request.contextPath}/testCookie">测试Cookie</a><br/>
<hr/>
<h3>响应数据</h3>
<a href="${pageContext.request.contextPath}/testModelAndView">testModelAndView</a><br/>
<a href="${pageContext.request.contextPath}/testModelMapAndModel">testModelMapAndModel</a><br/>
<button>ajax请求</button>
<script type="text/javascript">
    $(document).ready(function () {
        $('button').click(function () {
            // $.ajax({
            //     type: 'get',
            //     url: 'testJson',
            //     data: {
            //         name: "zhangsan",
            //         balance: 1000
            //     },
            //     dataType: 'json',
            //     success: function (data) {
            //         console.log(data);
            //     }
            // })

            $.ajax({
                type: 'post',
                url: 'testJsonString',
                data: JSON.stringify({"name": "zhangsan", "balance": 1000}),
                contentType: 'application/json;charset=utf-8',
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                }
            })
        })
    })
</script>
<h3>RESTful</h3>
<a href="${pageContext.request.contextPath}/testRESTful/zhangsan/1000">testRESTfull</a><br/>

<h3>统一异常处理</h3>
<a href="${pageContext.request.contextPath}/testException">testException</a><br/>

<h3>上传下载</h3>
<form action="${pageContext.request.contextPath}/testUpload" method="post" enctype="multipart/form-data">
    <label>上传文件:<input type="file" name="multipartFile"/></label>
    <hr/>
    <button type="submit">提交</button>
</form>
<a href="${pageContext.request.contextPath}/testDownload">下载文件</a>
<hr/>
<a href="${pageContext.request.contextPath}/ModelAttribute">ModelAttribute</a>
</body>
</html>
